#include <iostream>
#include <string>

auto convert_to(std::ostream & os, std::string const & line) {

    auto get_6_string = [](int number_of_6) -> std::string {
        if (number_of_6 > 9)        { return "27"; }
        else if (number_of_6 > 3)   { return "9"; }
        else                        { return std::string(number_of_6, '6'); }
    };

    int number_of_6 = 0;

    for (auto c : line) {
        if (c == '6') {
            number_of_6 += 1;
        } else {
            if (number_of_6 != 0) {
                os << get_6_string(number_of_6);
                number_of_6 = 0;
            }
            os << c;
        }
    }
    if (number_of_6 != 0) { os << get_6_string(number_of_6); }
}

int main() {
    std::string line;
    std::getline(std::cin, line);
    convert_to(std::cout, line);
}
